package edu.ucsd.db.bassarisk.algebra.logical;

import java.util.ArrayList;
import java.util.List;

import edu.ucsd.db.bassarisk.algebra.logical.visitor.LogicalOperatorVisitor;

public class Union extends LogicalOperator {
  private final List<LogicalOperator> unionPlans;

  public Union(List<LogicalOperator> unionPlans) {
    this.unionPlans = new ArrayList<LogicalOperator>();
    this.unionPlans.addAll(unionPlans);
  }

  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("Union {");
    for (LogicalOperator op : unionPlans) {
      sb.append("  ").append(op).append("");
    }
    sb.append("}");
    return sb.toString();
  }

  @Override
  public <R, A> R accept(LogicalOperatorVisitor<R, A> visitor, A arg) {
    return visitor.visitUnion(this, arg);
  }

  public Iterable<LogicalOperator> unionPlans() {
    return this.unionPlans;
  }
}
